package io.github.uicdb.et;

import com.mojang.serialization.Codec;
import io.github.uicdb.et.item_data.ItemCurioModifierData;
import io.github.uicdb.et.item_data.ItemElementData;
import net.minecraft.core.component.DataComponentType;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.codec.ByteBufCodecs;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.registries.DeferredRegister;

import java.util.function.Supplier;

public class ModItemDataComponents {
    private static final DeferredRegister<DataComponentType<?>> registry = DeferredRegister.create(BuiltInRegistries.DATA_COMPONENT_TYPE, ElementalTheory.MODID);
    public static final Supplier<DataComponentType<ItemElementData>> ITEM_ELEMENT_DATA = registry.register("item_element_data", () -> DataComponentType.<ItemElementData>builder().persistent(ItemElementData.CODEC).networkSynchronized(ItemElementData.STREAM_CODEC).cacheEncoding().build());
    public static final Supplier<DataComponentType<Boolean>> CURIO_INIT = registry.register("curio_init", () -> DataComponentType.<Boolean>builder().persistent(Codec.BOOL).networkSynchronized(ByteBufCodecs.BOOL).cacheEncoding().build());
    public static final Supplier<DataComponentType<ItemCurioModifierData>> ADDITION_ATTRIBUTE_MODIFIERS =registry.register(
            "addition_attribute_modifiers",
            ()-> DataComponentType.<ItemCurioModifierData>builder().persistent(ItemCurioModifierData.CODEC).networkSynchronized(ItemCurioModifierData.STREAM_CODEC).cacheEncoding().build()
    );

    public static void init(IEventBus bus) {
        registry.register(bus);
    }

}
